<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <h1>身体质量指数测试</h1>
    <input type="text" placeholder="请输入身高/m" v-model="h">
    <input type="text" placeholder="请输入体重/kg" v-model="w">
    <input type="button" value="开始测试" @click="f()">
    <h2>{{info}}</h2>
</div>
<!--引入Vue框架-->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!--引入Axios框架-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script>
    let v = new Vue({
        el:"body>div",
        data:{
            info:"测试结果",
            h:"",
            w:""
        },
        methods:{
            f(){
                axios.get("/bmi?h="+v.h+"&w="+v.w).then(function (response) {
                    //把请求回来的数据直接在页面展示
                    v.info = response.data;
                })
            }
        }
    })
</script>
</body>
</html>